package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.fasterxml.jackson.annotation.JsonBackReference;

/**
 * 
 */
@Entity
@Table(name = "tnb_role_serviceitem")
@JsonApiResource(type = "roleserviceitem")
public class RoleServiceItem extends BaseEntity {

	private Role role;
	private CustomerServiceItem item;


	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "role_id", foreignKey = @ForeignKey(name = "null"))
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault 
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "item_id", foreignKey = @ForeignKey(name = "null"))
	public CustomerServiceItem getItem() {
		return item;
	}

	public void setItem(CustomerServiceItem item) {
		this.item = item;
	}


}